package core.validate.rules;


import core.validate.ArrayRule;
import core.validate.Rule;
import core.validate.RuleTest;

import java.util.List;

public enum ArrayType {
    DISTINCT, HAS_VALUE, LENGTH, MIN, MAX, ITEM, TEST, EMPTY;
    public void apply(ArrayRule rule, List<Object> params, String message){
        switch (this) {
            case HAS_VALUE -> rule.hasValue(params.get(0), message);
            case LENGTH -> rule.length((Integer) params.get(0), message);
            case MIN -> rule.min((Integer) params.get(0), message);
            case MAX -> rule.max((Integer) params.get(0), message);
            case ITEM -> rule.item((Rule<?>) params.get(0));
            case TEST -> rule.test((RuleTest) params.get(0), message);
        }
    }
}
